#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
const int N=2e5+10;
int p[N],rp[N];
int e[N],ne[N],h[N],idx;
int deep[N];
bool ans[N];
int vis[N];
int tow[N];
int deepnow;
set<int> st[100010];
vector<int> d[100010];
struct node{
	int l,r;
	int x;
	int id;
}q[N];
bool cmp(node a, node b)
{
	return deep[a.x]>deep[b.x];
}
void add(int a, int b)
{
	e[idx]=b;
	ne[idx]=h[a];
	h[a]=idx++;;
}
void init(int n)
{
	idx=0;
	deepnow=0;
	for(int i=0;i<=n;i++) 
	{
		h[i]=-1;
		vis[i]=0;
		tow[i]=i;
		d[i].clear();
		st[i].clear();
		st[i].insert(i);
	}
}
void dfs(int u, int fa)
{
	for(int i=h[u];~i;i=ne[i])
	{
		int j=e[i];
		if(j==fa) continue;
		deep[j]=deep[u]+1;
		d[deep[j]].push_back(rp[j]);
		deepnow=max(deepnow,deep[j]);
 		st[tow[rp[u]]].insert(rp[j]);
 		dfs(j,u);
	}
}
void merge(int dep)
{
	for(auto i:d[dep])
	{
		set<int> cp=st[tow[i]];
	    for(auto j:cp)
	    {
	    	if(st[tow[i]].size()>=st[tow[j]].size())
	    	{
	    		for(auto k:st[tow[j]])
	    		{
	    			st[tow[i]].insert(k);
				}
			}
			else
			{
				for(auto k:st[tow[i]])
	    		{
	    			st[tow[j]].insert(k);
				}
				tow[i]=tow[j];
			}
		}
	}
}
void solve()
{
	int n,m;
	cin>>n>>m;
	init(n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		cin>>u>>v;
		add(u,v);
		add(v,u);
	}
	for(int i=1;i<=n;i++) cin>>p[i], rp[p[i]]=i;
	deep[1]=0;
	d[0].push_back(rp[1]);
	dfs(1,-1);
	for(int i=1;i<=m;i++)
	{
		cin>>q[i].l>>q[i].r>>q[i].x;
		q[i].id=i;
	}
	sort(q+1,q+1+m,cmp);
	deepnow-=1;
	for(int i=1;i<=m;i++)
	{
		int l=q[i].l, r=q[i].r, x=q[i].x, id=q[i].id;
		if(deepnow>deep[x])
		{
			for(deepnow; deepnow>deep[x]; deepnow--)
			{
				merge(deepnow-1);
			}
		}
	    int pos = *st[tow[rp[x]]].lower_bound(l);
		if(pos>=l && pos<=r) ans[id]=1;
		else ans[id]=0;
	}
	for(int i=1;i<=m;i++)
	{
		if(ans[i]) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	cout<<endl;

}
int main()
{
	IOS;
	int T=1;
	cin>>T;

	while(T--)
	{
		solve();
	}

	return 0;
}

